﻿Imports System.Data.OleDb
Imports System.Data.OracleClient
Imports System.IO
Imports ccapps.persistent.GPO2Avea
Public Class GPOPrepaidToAveaPostpaidCustomerCreate
    Inherits System.Web.UI.Page
    Dim i As Integer
    Dim a As Integer



    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


        If Session("user") = "" Or Session("user") Is Nothing Then
            Session("message") = "!!Session Timeout!!,Tekrar Giriş Yapmalısınız"
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()
        End If
        'Adrss checkbox için adr_ROLES die bir variable dolduruluyor.Her checkbox için bir harf var en azından eb alıyor'


        HidTable1.Visible = False
        hidTable2.Visible = False
        KurumsalTable.Visible = False
        MevcutTable.Visible = False


        If lblcode.Text = "hidtable" Then
            HidTable1.Visible = True
            hidTable2.Visible = False
            KurumsalTable.Visible = False
            MevcutTable.Visible = False
        End If

        If lblcode.Text = "kurumsal" Then
            KurumsalTable.Visible = True
            HidTable1.Visible = False
            hidTable2.Visible = False
            MevcutTable.Visible = False
        End If

        If lblcode.Text = "mevcut" Then
            KurumsalTable.Visible = True
            HidTable1.Visible = False
            hidTable2.Visible = False
            MevcutTable.Visible = True
        End If

        If lblcode.Text = "kurumsalYeni" Then
            HidTable1.Visible = False
            hidTable2.Visible = True
            KurumsalTable.Visible = True
            MevcutTable.Visible = False

        End If

        'If i = 1 Then
        '    KurumsalTable.Visible = True

        '    If a = 1 Then
        '        MevcutTable.Visible = True
        '        HidTable1.Visible = False
        '        KurumsalTable.Visible = True
        '    End If

        '    If a = 2 Then
        '        hidTable2.Visible = True
        '        HidTable1.Visible = False
        '        KurumsalTable.Visible = True
        '    End If
        'End If

        'If i = 2 Then
        '    KurumsalTable.Visible = True
        '    MevcutTable.Visible = True
        '    HidTable1.Visible = False
        '    hidTable2.Visible = False


        'End If



    End Sub




    Private Sub TarifeSecim()

        Try
            If (DLL_PRG_CODE.SelectedItem.ToString() = "--Seçiniz--") Then

            Else
                DLL_RPCODE.Items.Clear()
                Dim musteri_code As Integer = DLL_PRG_CODE.SelectedValue



                Dim dt3 As DataTable = TarifeType(musteri_code)

                If dt3.Rows.Count > 0 Then
                    For Each dr3 As DataRow In dt3.Rows
                        DLL_RPCODE.Items.Add(New ListItem(dr3("des").ToString(), dr3("tmcode").ToString()))

                    Next
                End If

            End If
        Catch ex As Exception
            lblcode.Text = ex.ToString()

        End Try
      


    End Sub


    Private Sub KimlikSecim()

        Try
            Dim dt As DataTable = KimlikType()

            If dt.Rows.Count > 0 Then
                For Each dr As DataRow In dt.Rows
                    DDL_IDTYPE_CODE.Items.Add(New ListItem(dr("IDTYPE_NAME").ToString(), dr("IDTYPE_CODE").ToString()))
                Next
            End If
        Catch ex As Exception
            lblcode.Text = ex.ToString()

        End Try
        
    End Sub

    Private Sub MusteriGrubu()

        Try
            Dim dt As DataTable = getcustomertype()

            If dt.Rows.Count > 0 Then
                For Each dr As DataRow In dt.Rows
                    DLL_PRG_CODE.Items.Add(New ListItem(dr("prgname").ToString(), dr("prgcode").ToString()))
                Next
            End If
        Catch ex As Exception
            lblcode.Text = ex.ToString()

        End Try
        
    End Sub

    Private Sub UlkeSecim()

        Try
            Dim dt As DataTable = CountryType()
            If dt.Rows.Count > 0 Then
                For Each dr As DataRow In dt.Rows
                    DDL_ADR_NATIONALITY.Items.Add(New ListItem(dr("NAME").ToString(), dr("COUNTRY_ID").ToString()))
                Next
            End If
        Catch ex As Exception
            lblcode.Text = ex.ToString()

        End Try
        
    End Sub


    Private Sub IlceSecim()

        Try
            If (DDL1_ADR_CITY.SelectedItem.ToString() = "--Seçiniz--") Then

            Else
                DDL1_ADR_NOTE1.Items.Clear()
                Dim citycode As Integer = DDL1_ADR_CITY.SelectedValue



                Dim dt3 As DataTable = IlceType(citycode)

                If dt3.Rows.Count > 0 Then
                    For Each dr3 As DataRow In dt3.Rows
                        DDL1_ADR_NOTE1.Items.Add(New ListItem(dr3("DIST_DES").ToString(), dr3("DIST_COD").ToString()))

                    Next
                End If
            End If
        Catch ex As Exception
            lblcode.Text = ex.ToString()

        End Try
       

    End Sub





    Private Sub IlSecim()


        Try
            Dim dt3 As DataTable = IlType()

            If dt3.Rows.Count > 0 Then
                For Each dr3 As DataRow In dt3.Rows
                    DDL1_ADR_CITY.Items.Add(New ListItem(dr3("ctydes").ToString(), dr3("ctycod").ToString()))

                Next
            End If
        Catch ex As Exception
            lblcode.Text = ex.ToString()

        End Try
       
    End Sub




    Private Sub AktivasyonReason()
        Try
            Dim dt2 As DataTable = aktivasyonType()


            If dt2.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt2.Rows
                    DLL_RS_CODE.Items.Add(New ListItem(dr2("rs_desc").ToString(), dr2("RS_ID").ToString())) 'rs_desc ve rscode Databasedeki sql variablelarının isimleri' 
                Next
            End If
        Catch ex As Exception
            lblcode.Text = ex.ToString()

        End Try
        
    End Sub
    Protected Sub RadioButtonList1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RadioButtonList1.SelectedIndexChanged
        If RadioButtonList1.SelectedIndex = 0 Then
            HidTable1.Visible = True
            hidTable2.Visible = False
            KurumsalTable.Visible = False
            MevcutTable.Visible = False

            MusteriGrubu()
            AktivasyonReason()
            IlSecim()
            IlceSecim()
            TarifeSecim()
            UlkeSecim()
            KimlikSecim()
            DDL_ADR_NATIONALITY.SelectedIndex = 1 'Seçili ülkeyi Türkiye Yapar
            lblcode.Text = "hidtable"

        End If
        If RadioButtonList1.SelectedIndex = 1 Then
            KurumsalTable.Visible = True
            HidTable1.Visible = False
            hidTable2.Visible = False
            MevcutTable.Visible = False
            MusteriGrubuSME()
            AktivasyonReasonSME()
            IlSecimSME()
            KimlikSecimSME()
            lblcode.Text = "kurumsal"

        End If

    End Sub
    Protected Sub RadioButtonList2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RadioButtonList2.SelectedIndexChanged
        If RadioButtonList2.SelectedIndex = 0 Then
            MevcutTable.Visible = True
            HidTable1.Visible = False
            hidTable2.Visible = False
            KurumsalTable.Visible = True
            i = 1
            a = 1
            lblcode.Text = "mevcut"

        End If
        If RadioButtonList2.SelectedIndex = 1 Then
            hidTable2.Visible = True
            HidTable1.Visible = False
            MevcutTable.Visible = False
            KurumsalTable.Visible = True
            i = 1
            a = 2
            lblcode.Text = "kurumsalYeni"

        End If

    End Sub
    Protected Sub DDL1_ADR_CITY_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDL1_ADR_CITY.SelectedIndexChanged
        HidTable1.Visible = True
        IlceSecim()
    End Sub

    Protected Sub DLL_PRG_CODE_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DLL_PRG_CODE.SelectedIndexChanged
        HidTable1.Visible = True
        TarifeSecim()

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim confirmValue As String = Request.Form("confirm_value")
        If confirmValue = "Yes" Then
            Dim now As DateTime = DateTime.Now
            Dim tarih As String = TDD_ADR_BIRTHDT.Text.Trim()
            Dim tarih2 As DateTime = Convert.ToDateTime(tarih)

            ' DateTime date1 = new DateTime(2013, 7, 22);
            Dim result As Integer = DateTime.Compare(tarih2, now) 'küçük ise -1; büyük ise 1;"
            If result = -1 Then
                Try

                    Dim nationality As Integer = Convert.ToInt32(DDL_ADR_NATIONALITY.SelectedValue)
                    Dim tc_id As String = TB_CS_TC_ID.Text.Trim()
                    Button1.Enabled = False
                    Dim fname As String = TB_ADR_FNAME.Text.Trim()
                    Dim lname As String = TB_ADR_LNAME.Text.Trim()
                    Dim remark1 As String = TB_CS_REMARK1.Text.Trim()
                    Dim birth_pv As String = TB_CS_BIRTH_PROVINCE.Text
                    Dim remark2 As String = TB_CS_REMARK2.Text.Trim()
                    Dim birth As String = TDD_ADR_BIRTHDT.Text.Trim()
                    Dim reg_pv As String = TB_CS_REG_PROVINCE.Text.Trim()
                    Dim reg_dis As String = TB_CS_REG_DISTRICT.Text.Trim()
                    Dim sex As String = DDL_ADR_SEX.SelectedValue
                    Dim idtype As Integer = Convert.ToInt32(DDL_IDTYPE_CODE.SelectedValue)
                    Dim idno As String = TB_ADR_IDNO.Text.Trim()
                    Dim prgcode As String = DLL_PRG_CODE.SelectedValue
                    Dim rpcode As Integer = Convert.ToInt32(DLL_RPCODE.SelectedValue)
                    Dim rscode As Integer = Convert.ToInt32(DLL_RS_CODE.SelectedValue)
                    Dim city As String = DDL1_ADR_CITY.SelectedItem.ToString()
                    Dim adr_note1 As String = DDL1_ADR_NOTE1.SelectedItem.ToString()
                    Dim street As String = TB1_ADR_STREET.Text.Trim()
                    Dim zip As String = TB1_ADR_ZIP.Text.Trim()
                    Dim street_no As String = TB1_ADR_STREETNO.Text.Trim()
                    Dim pharea1 As String = TB_ADR_PHN1_AREA.Text.Trim()
                    Dim phone1 As String = TB_ADR_PHN1.Text.Trim()
                    Dim pharea2 As String = TB_ADR_PHN2_AREA.Text.Trim()
                    Dim phone2 As String = TB_ADR_PHN2.Text.Trim()
                    Dim email As String = TB_ADR_EMAIL.Text.Trim()
                    Dim sms As String = TB_ADR_SMSNO.Text.Trim()
                    Dim adr_note2 As String = TB_ADR_NOTE2.Text
                    Dim mernis_status As Integer = Convert.ToInt32(lblMernisStatus.Text)

                    Dim request As String = "saddsaasd"
                    Dim MES As String



                    Dim res As DataTable = CreateCustomer(nationality, tc_id, fname, lname, remark1, birth_pv, remark2, birth,
                reg_pv, reg_dis, sex, idtype, idno, prgcode, rpcode, rscode, "BUPE",
                city, adr_note1, street, zip, street_no, pharea1, phone1, pharea2, phone2, sms, email, adr_note2, mernis_status, MES)







                    If res.Rows.Count > 0 Then
                        For Each dr2 As DataRow In res.Rows

                            If (dr2("CUSTOMER_ID").ToString() <> "-1") Then
                                Session("customer_id") = dr2("CUSTOMER_ID").ToString()
                                Session("tarife") = rpcode
                                Session("cust_type") = "bireysel"
                                Response.Redirect("Gpo2AveaContractCreate.aspx", False)

                            End If




                        Next

                    End If


                Catch ex As Exception


                    Session("message") = ex.Message
                    Response.Clear()
                    Response.Status = "302 Object Moved"
                    Response.RedirectLocation = "CX_Exception.aspx"
                    Response.End()
                    Button1.Enabled = True



                End Try
            Else
                Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('Girilen Tarih İleri Bir Tarih Olamaz.');</script>")
            End If
        Else
            HidTable1.Visible = True

        End If
    End Sub
    Private Sub VergiSicil()

        Dim sicilno As String = Mevcut_TB_CSCOMPTAXNO.Text

        Dim dt2 As DataTable = SMEVergiSearch(sicilno)


        If dt2.Rows.Count > 0 Then
            For Each dr2 As DataRow In dt2.Rows

                MevcutAd.Text = dr2("ccfname").ToString() + "    " + dr2("cclname").ToString() + "," + dr2("CCCITY").ToString()
                MevcutCustomer_id.Text = dr2("CUSTOMER_ID").ToString()
                MevcutSicil.Text = Mevcut_TB_CSCOMPTAXNO.Text
                Button5.Enabled = True
                ErrorMessage.Text = ""

            Next
        Else
            Button5.Enabled = False
            ErrorMessage.Text = "Girmiş olduğunuz custcode için veri yoktur"
            If sicilno = "" Then
                ErrorMessage.Text = ""
            End If

        End If
    End Sub


    Private Sub CustcodeSearch()
        Try
            Dim custcode As String = TB_CustCode.Text.Trim()

            Dim dt2 As DataTable = SMECustCodeSearch(custcode)


            If dt2.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt2.Rows

                    MevcutAd.Text = dr2("ccfname").ToString() + "       " + dr2("cclname").ToString() + "," + dr2("CCCITY").ToString()
                    MevcutCustomer_id.Text = dr2("CUSTOMER_ID").ToString()
                    MevcutSicil.Text = dr2("CSCOMPTAXNO").ToString()
                    Button5.Enabled = True
                    ErrorMessage.Text = ""

                Next

            Else
                Button5.Enabled = False
                ErrorMessage.Text = "Girmiş olduğunuz custcode için veri yoktur"

            End If
        Catch ex As Exception
            ErrorMessage.Text = ex.ToString()

        End Try





    End Sub

    Protected Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
        i = 2
        VergiSicil()
        MevcutTable.Visible = True
        HidTable1.Visible = False
        KurumsalTable.Visible = True
    End Sub


    Protected Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        Dim confirmValue As String = Request.Form("confirm_value")
        If confirmValue = "Yes" Then
            Session("customer_id") = MevcutCustomer_id.Text
            Session("durum") = "MevcutSME" ' burada customer id nin SME'nin mevcut tablosundan geldiğini belirtilmistir
            Response.Redirect("Gpo2AveaContractCreate.aspx")
        Else
            MevcutTable.Visible = True

        End If


    End Sub

    Protected Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
        i = 2
        CustcodeSearch()
        MevcutTable.Visible = True
        HidTable1.Visible = False
        KurumsalTable.Visible = True
    End Sub

    Protected Sub DLL_RPCODE_SelectedIndexChanged(sender As Object, e As EventArgs)

    End Sub

    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim confirmValue As String = Request.Form("confirm_value")
        If confirmValue = "Yes" Then
            Dim now As DateTime = DateTime.Now
            Dim tarih As String = SME_TDD_ADR_BIRTHDT.Text.Trim()
            Dim tarih2 As DateTime = Convert.ToDateTime(tarih)

            ' DateTime date1 = new DateTime(2013, 7, 22);
            Dim result As Integer = DateTime.Compare(tarih2, now) 'küçük ise -1; büyük ise 1;"
            If result = -1 Then
                Try

                    Dim adr_name As String = TB_ADR_NAME.Text
                    Dim adr_taxno As String = TB_ADR_TAXNO.Text
                    Dim adr_compno As String = TB_ADR_COMPNO.Text
                    Dim tc_id As String = SME_TB_CS_TC_ID.Text
                    Dim fname As String = SME_TB_ADR_FNAME.Text
                    Dim lname As String = SME_TB_ADR_LNAME.Text
                    Dim remark1 As String = SME_TB_CS_REMARK1.Text
                    Dim birth_pv As String = SME_TB_CS_BIRTH_PROVINCE.Text
                    Dim remark2 As String = SME_TB_CS_REMARK2.Text
                    Dim birth As String = SME_TDD_ADR_BIRTHDT.Text
                    Dim reg_pv As String = SME_TB_CS_REG_PROVINCE.Text
                    Dim reg_dis As String = SME_TB_CS_REG_DISTRICT.Text
                    Dim sex As String = SME_DDL_ADR_SEX.SelectedValue
                    Dim idtype As Integer = Convert.ToInt32(SME_DDL_IDTYPE_CODE.SelectedValue)
                    Dim idno As String = SME_TB_ADR_IDNO.Text
                    Dim prgcode As String = SME_DLL_PRG_CODE.SelectedValue
                    Dim rpcode As Integer = Convert.ToInt32(SME_DLL_RPCODE.SelectedValue)
                    Dim rscode As Integer = Convert.ToInt32(SME_DLL_RS_CODE.SelectedValue)
                    Dim city As String = SME_DDL1_ADR_CITY.SelectedItem.ToString()
                    Dim adr_note1 As String = SME_DDL1_ADR_NOTE1.SelectedItem.ToString()
                    Dim street As String = SME_TB1_ADR_STREET.Text
                    Dim zip As String = SME_TB1_ADR_ZIP.Text
                    Dim street_no As String = SME_TB1_ADR_STREETNO.Text
                    Dim pharea1 As String = SME_TB_ADR_PHN1_AREA.Text
                    Dim phone1 As String = SME_TB_ADR_PHN1.Text
                    Dim pharea2 As String = SME_TB_ADR_PHN2_AREA.Text
                    Dim phone2 As String = SME_TB_ADR_PHN2.Text
                    Dim sms As String = SME_TB_ADR_SMSNO.Text
                    Dim email As String = SME_TB_ADR_EMAIL.Text
                    Dim adr_note2 As String = TB_SME_ADR_NOTE2.Text
                    Dim mernis_status As Integer = Convert.ToInt32(lblMernisStatus.Text)
                    Dim MES As String 'Message from the database
                    If (lblTcIdControlError.Text = "") Then


                        Dim res As DataTable = CreateCustomerSME(adr_name, adr_taxno, adr_compno, tc_id, fname, lname, remark1, birth_pv, remark2, birth,
                         reg_pv, reg_dis, sex, idtype, idno, prgcode, rpcode, rscode, "BUPE",
                         city, adr_note1, street, zip, street_no, pharea1, phone1, pharea2, phone2, sms, email, adr_note2, mernis_status, MES)




                        If res.Rows.Count > 0 Then
                            For Each dr2 As DataRow In res.Rows

                                If (dr2("CUSTOMER_ID").ToString() <> "-1") Then
                                    Session("customer_id") = dr2("CUSTOMER_ID").ToString()
                                    Session("tarife") = rpcode
                                    Response.Redirect("GPO2AveaContractCreate.aspx", False)
                                    Button2.Enabled = True
                                End If




                            Next

                        End If
                        ' Yeni Oluşturulan Customer Id'nin Billing Net Görüntülenmesi

                        '
                    End If
                Catch ex As Exception


                    Session("message") = ex.Message
                    Response.Clear()
                    Response.Status = "302 Object Moved"
                    Response.RedirectLocation = "CX_Exception.aspx"
                    Response.End()
                    Button2.Enabled = True



                End Try
            Else
                Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('Girilen Tarih İleri Bir Tarih Olamaz.');</script>")
            End If
        Else
            hidTable2.Visible = True

        End If


    End Sub



    Private Sub TarifeSecimSME()
        Try
            If (SME_DLL_PRG_CODE.SelectedItem.ToString() = "--Seçiniz--") Then
            Else
                SME_DLL_RPCODE.Items.Clear()
                Dim musteri_code As Integer = SME_DLL_PRG_CODE.SelectedValue



                Dim dt3 As DataTable = TarifeTypeSME(musteri_code)

                If dt3.Rows.Count > 0 Then
                    For Each dr3 As DataRow In dt3.Rows
                        SME_DLL_RPCODE.Items.Add(New ListItem(dr3("des").ToString(), dr3("tmcode").ToString()))

                    Next
                End If

            End If
        Catch ex As Exception
            lblcode.Text = ex.ToString()

        End Try
    End Sub


    Private Sub KimlikSecimSME()
        Try
            Dim dt As DataTable = KimlikType()

            If dt.Rows.Count > 0 Then
                For Each dr As DataRow In dt.Rows
                    SME_DDL_IDTYPE_CODE.Items.Add(New ListItem(dr("IDTYPE_NAME").ToString(), dr("IDTYPE_CODE").ToString()))
                Next
            End If
        Catch ex As Exception
            lblcode.Text = ex.ToString()

        End Try

    End Sub

    Private Sub MusteriGrubuSME()
        Try
            Dim dt As DataTable = getcustomertypeSME()

            If dt.Rows.Count > 0 Then
                For Each dr As DataRow In dt.Rows
                    SME_DLL_PRG_CODE.Items.Add(New ListItem(dr("prgname").ToString(), dr("prgcode").ToString()))
                Next
            End If
        Catch ex As Exception
            lblcode.Text = ex.ToString()

        End Try

    End Sub



    Private Sub IlceSecimSME()

        Try
            If (SME_DDL1_ADR_CITY.SelectedItem.ToString() = "--Seçiniz--") Then

            Else
                SME_DDL1_ADR_NOTE1.Items.Clear()
                Dim citycode As Integer = SME_DDL1_ADR_CITY.SelectedValue
                Dim dt3 As DataTable = IlceType(citycode)
                If dt3.Rows.Count > 0 Then
                    For Each dr3 As DataRow In dt3.Rows
                        SME_DDL1_ADR_NOTE1.Items.Add(New ListItem(dr3("DIST_DES").ToString(), dr3("DIST_COD").ToString()))

                    Next
                End If
            End If
        Catch ex As Exception
            lblcode.Text = ex.ToString()

        End Try


    End Sub





    Private Sub IlSecimSME()
        Try
            Dim dt3 As DataTable = IlType()

            If dt3.Rows.Count > 0 Then
                For Each dr3 As DataRow In dt3.Rows
                    SME_DDL1_ADR_CITY.Items.Add(New ListItem(dr3("ctydes").ToString(), dr3("ctycod").ToString()))

                Next
            End If
        Catch ex As Exception
            lblcode.Text = ex.ToString()

        End Try

    End Sub




    Private Sub AktivasyonReasonSME()
        Try
            Dim dt2 As DataTable = aktivasyonType()
            If dt2.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt2.Rows
                    SME_DLL_RS_CODE.Items.Add(New ListItem(dr2("rs_desc").ToString(), dr2("RS_ID").ToString())) 'rs_desc ve rscode Databasedeki sql variablelarının isimleri' 
                Next
            End If
        Catch ex As Exception
            lblcode.Text = ex.ToString()

        End Try

    End Sub

    Protected Sub SME_DDL1_ADR_CITY_SelectedIndexChanged(sender As Object, e As EventArgs) Handles SME_DDL1_ADR_CITY.SelectedIndexChanged
        hidTable2.Visible = True
        KurumsalTable.Visible = True
        IlceSecimSME()
    End Sub

    Protected Sub SME_DLL_PRG_CODE_SelectedIndexChanged(sender As Object, e As EventArgs) Handles SME_DLL_PRG_CODE.SelectedIndexChanged
        hidTable2.Visible = True
        KurumsalTable.Visible = True
        TarifeSecimSME()
    End Sub


    Protected Sub DDL_ADR_NATIONALITY_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDL_ADR_NATIONALITY.SelectedIndexChanged
        HidTable1.Visible = True

        If (DDL_ADR_NATIONALITY.SelectedValue = 2) Then
            TB_CS_TC_ID.Enabled = True
            btnTcDogrulama.Visible = True
            btnTcDogrulama.Enabled = True
            TB_CS_TC_ID.Visible = True
            RequiredFieldValidator1.ControlToValidate = "TB_CS_TC_ID"
            HidTable1.Visible = True
        End If

        If (DDL_ADR_NATIONALITY.SelectedValue <> 2) Then
            btnTcDogrulama.Enabled = False
            btnTcDogrulama.Visible = False
            TB_CS_TC_ID.Enabled = False
            TB_CS_TC_ID.Visible = False
        End If
    End Sub




    Protected Sub btnTcDogrulama_Click(sender As Object, e As EventArgs) Handles btnTcDogrulama.Click
        HidTable1.Visible = True
        If TB_CS_TC_ID.Text = "" Then
            Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No Alanı Boş Değer İçermez.');</script>")
        Else
            Try
                Dim d As Double = Double.Parse(TB_CS_TC_ID.Text)
                If TB_CS_TC_ID.Text.Length = 11 Then
                    Dim name, surname, gender, fatherName, birthDay, birthMonth, birthYear, cityName, countyName, anneKizlikSoyad, birthPlace As String
                    If (persistent.ChangeSIMpersistence.CheckMernisStatus2(TB_CS_TC_ID.Text, name, surname, gender, fatherName, birthDay, birthMonth, birthYear, cityName, countyName, anneKizlikSoyad, birthPlace) = "0") Then


                        lblTcIdControlError.Text = "Geçerli TC No"
                        TB_ADR_FNAME.Text = name
                        TB_ADR_LNAME.Text = surname
                        TB_CS_REMARK1.Text = fatherName
                        TB_CS_REMARK2.Text = anneKizlikSoyad
                        TDD_ADR_BIRTHDT.Text = birthDay + "." + birthMonth + "." + birthYear
                        TB_CS_BIRTH_PROVINCE.Text = birthPlace
                        TB_CS_REG_PROVINCE.Text = cityName
                        TB_CS_REG_DISTRICT.Text = countyName
                        If gender = "Erkek" Then
                            DDL_ADR_SEX.SelectedIndex = 1
                        ElseIf gender = "Kadın" Then
                            DDL_ADR_SEX.SelectedIndex = 2
                        Else
                            DDL_ADR_SEX.SelectedIndex = 0
                        End If
                        lblMernisStatus.Text = 1

                        If persistent.ChangeSIMpersistence.CheckGreyList(TB_CS_TC_ID.Text) = "0" Then
                            lblTcIdControlError.Text = lblTcIdControlError.Text + " ve " + "TC Kullanıma Uygundur"
                            Button1.Enabled = True
                        ElseIf persistent.ChangeSIMpersistence.CheckGreyList(TB_CS_TC_ID.Text) = "1" Then
                            lblTcIdControlError.Text = "TC Blacklistedir"
                            Button1.Enabled = False
                        ElseIf persistent.ChangeSIMpersistence.CheckGreyList(TB_CS_TC_ID.Text) = "11" Then
                            lblTcIdControlError.Text = "TC Greylistdedir"
                            Button1.Enabled = False
                        Else
                            lblTcIdControlError.Text = "TC Kullanıma Uygun Değildir"
                        End If


                    Else

                        lblTcIdControlError.Text = "TC No geçerli değildir Lütfen tekrar deneyiniz"
                        lblMernisStatus.Text = 2

                        Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No geçerli değildir Lütfen tekrar deneyiniz');</script>")

                    End If


                Else
                    lblTcIdControlError.Text = "TC No 11 Karakter Olmalıdır"
                    Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No Alanı 11 Karakter Olmalıdır');</script>")

                End If

            Catch ex As Exception
                Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No Alanı Harf İçermez.');</script>")
            End Try

        End If


    End Sub

    Protected Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
        hidTable2.Visible = True
        If SME_TB_CS_TC_ID.Text = "" Then

            Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No Alanı Boş Değer İçermez.');</script>")

        Else

            Try

                Dim d As Double = Double.Parse(SME_TB_CS_TC_ID.Text)

                If SME_TB_CS_TC_ID.Text.Length = 11 Then

                    Dim name, surname, gender, fatherName, birthDay, birthMonth, birthYear, cityName, countyName, anneKizlikSoyad, birthPlace As String

                    If (persistent.ChangeSIMpersistence.CheckMernisStatus2(SME_TB_CS_TC_ID.Text, name, surname, gender, fatherName, birthDay, birthMonth, birthYear, cityName, countyName, anneKizlikSoyad, birthPlace) = "0") Then



                        lblTcIdControlError.Text = "Geçerli TC No"
                        SME_TB_ADR_FNAME.Text = name
                        SME_TB_ADR_LNAME.Text = surname
                        SME_TB_CS_REMARK1.Text = fatherName
                        SME_TB_CS_REMARK2.Text = anneKizlikSoyad
                        SME_TDD_ADR_BIRTHDT.Text = birthDay + "." + birthMonth + "." + birthYear
                        SME_TB_CS_BIRTH_PROVINCE.Text = birthPlace
                        SME_TB_CS_REG_PROVINCE.Text = cityName
                        SME_TB_CS_REG_DISTRICT.Text = countyName
                        If gender = "Erkek" Then
                            SME_DDL_ADR_SEX.SelectedIndex = 1
                        ElseIf gender = "Kadın" Then
                            SME_DDL_ADR_SEX.SelectedIndex = 2
                        Else
                            SME_DDL_ADR_SEX.SelectedIndex = 0
                        End If
                        lblMernisStatus.Text = 1

                        If persistent.ChangeSIMpersistence.CheckGreyList(TB_CS_TC_ID.Text) = "0" Then
                            lblTcIdControlError.Text = lblTcIdControlError.Text + " ve " + "TC Kullanıma Uygundur"
                            Button2.Enabled = True

                        ElseIf persistent.ChangeSIMpersistence.CheckGreyList(TB_CS_TC_ID.Text) = "1" Then
                            lblTcIdControlError.Text = "TC Blacklistedir"
                            Button2.Enabled = False
                        ElseIf persistent.ChangeSIMpersistence.CheckGreyList(TB_CS_TC_ID.Text) = "11" Then
                            lblTcIdControlError.Text = "TC Greylistdedir"
                            Button2.Enabled = False
                        Else
                            lblTcIdControlError.Text = "TC Kullanıma Uygun Değildir"
                        End If


                    Else

                        lblTcIdControlError.Text = "TC No geçerli değildir Lütfen tekrar deneyiniz"
                        lblMernisStatus.Text = 2

                        Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No geçerli değildir Lütfen tekrar deneyiniz');</script>")



                    End If

                Else

                    lblTcIdControlError.Text = "TC No Alanı 11 Karakter Olmalıdır."

                    Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No Alanı 11 Karakter Olmalıdır');</script>")



                End If

            Catch ex As Exception

                Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No Alanı Harf İçermez.');</script>")

            End Try



        End If


    End Sub

    Protected Sub SME_DLL_RPCODE_SelectedIndexChanged(sender As Object, e As EventArgs)

    End Sub
End Class
    